home *** CD-ROM | disk | FTP | other *** search
- /*12/05/95 E. L. L.*/
- /*YAESU FT-767GX CAT (Computer Aided Tuning or Transceive) PROGRAM*/
- /*Setup to use serial port com1 and operate on a 486 machine*/
-
- #include <stdio.h>
- #include <conio.h>
- #include <bios.h>
- #include <graph.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- #include <process.h>
- #define ESC 27
- #define clrscr() system("cls")
- #define CLRSCR printf("%c[2J",ESC)
- #define FALSE 0
- #define TRUE 1
- #define CLREOL printf("%c[K",ESC)
- #define EDTB "\0"
- #define BACKSPACE printf("\010")
- #define PAD 2
- #define FACTOR 800
- #define TIMEOUT 18000
- #define MAXGENERAL 100
- #define MAXREPEATER 25
-
- void examine_files(int num);
- void disk_memory_control(void);
- int selection(int choice);
- int add_station(int num);
- int delete_station(int num);
- int getreply(void);
- void backup(int spaces);
- int gen_insert(int rcnt , int num);
- int loadfile(int num);
- int rep_insert(int rcnt , int num);
- int savedata(int maxcnt, int num);
- void input_data(int num);
- void remove_record(int del , int cnt , int num);
- void reindex(int cnt , int num , int j);
- void viewfile(int cnt , int num);
- void press_enter(int x, int y);
- char *convert(char *buff , char *freq);
- void recall(int num);
- void do_it(char *func);
- void store(int num);
- char *hertz(char *buffer, int k);
- void vfo_mode(int m);
- void get_data(int num);
- void pl_tone(int b);
- void edit_control(void);
- char edit_selection(char opt);
- void edit_records(int num);
- void edit_station_record(int rec, int num);
-
- struct general
- {
- char rec[3 + PAD];
- char freq[8 + PAD];
- char mode[3 + PAD];
- char call[8 + PAD];
- char loc[34 + PAD];
- };
- struct general g[MAXGENERAL];
- struct general gentemp,*ptg1,*ptg2;
-
- struct repeater
- {
- char rec[3 + PAD];
- char afreq[8 + PAD];
- char bfreq[8 + PAD];
- char mode[3 + PAD];
- char tone[6 + PAD];
- char call[8 + PAD];
- char loc[34 + PAD];
- };
- struct repeater r[MAXREPEATER];
- struct repeater reptemp,*ptr1,*ptr2;
-
- char cmd[10],modifier[15],binary[8];
- char *lstr[] = { "67.0","71.9","77.0","82.5","88.5","94.8","100.0","103.5",
- "107.2","110.9","114.8","118.8","123.0","127.3","131.8",
- "136.5","141.3","146.2","151.4","156.7","162.2","167.9",
- "173.8","179.9","186.2","192.8","203.5","210.7","218.1",
- "225.7","233.6","241.8","250.3",EDTB };
-
- char *hstr[] = { "67.0","71.9","74.7","77.0","79.7","82.5","85.4","88.5",
- "91.5",EDTB };
-
- char **ptr;
- int status[90],bytcnt,clear;
- int catflag,endprog;
- int xmiterror;
-
- parse(chptr)
- char *chptr;
- {
- char *mod;
- int k;
- for(k=0;k<=15;k++)
- modifier[k] = 0;
- mod = modifier;
- k = 0;
- while((*chptr != 0) && (*chptr != ' '))
- {
- *chptr++;
- k++;
- }
- if(*chptr == ' ')
- {
- *chptr++;
- while(*chptr != 0)
- *mod++ = *chptr++;
- }
- return(k);
- } /*end of parse*/
-
- void match(func,cnt)
- char *func;
- int cnt;
- {
- char *up,*dn,*cat,*band,*split,*clar,*mtov,*vtom,*swap,*prog;
- char *freq,*vfo,*mem,*mode,*ham,*tone,*check,*aclr,*quit;
- char *on,*off,*gen,*a,*b,*mr,*lsb,*usb,*cw,*am,*fm,*fsk;
- char *hiq,*loq,*m0,*m1,*m2,*m3,*m4,*m5,*m6,*m7,*m8,*m9;
- char *help;
-
- up = "up"; dn= "dn"; cat= "cat"; off = "off"; on = "on"; band = "band";
- split = "split"; clar = "clar"; mtov = "mtov"; vtom = "vtom"; swap = "swap";
- prog = "prog";hiq = "hiq";loq = "loq"; freq = "freq";
- vfo = "vfo"; a = "a"; b = "b"; mr = "mr"; mem = "mem"; m0 = "0";
- m1 = "1"; m2 = "2"; m3 = "3"; m4 = "4"; m5 = "5"; m6 = "6"; m7 = "7";
- m8 = "8"; m9 = "9"; mode = "mode"; lsb = "lsb"; usb = "usb"; cw = "cw";
- am = "am"; fm = "fm"; fsk = "fsk"; ham = "ham"; gen = "gen";
- tone = "tone"; check = "check"; aclr = "aclr"; quit = "quit"; help = "help";
-
- if((strncmp(func,up,cnt) == 0) && (cnt == 2))
- {
- bytcnt = 5;
- cmd[4] = 0x2;
- return;
- }
- else
- if((strncmp(func,dn,cnt) == 0) && (cnt == 2))
- {
- bytcnt = 5;
- cmd[4] = 0x3;
- return;
- }
- else
- if((strncmp(func,cat,cnt) == 0) && (cnt == 3))
- {
- bytcnt = 86;
- cmd[4] = 0x0;
- if(strcmp(modifier,on) == 0)
- {
- cmd[3] = 0x0;
- catflag = TRUE;
- }
- else
- if(strcmp(modifier,off) == 0)
- {
- cmd[3] = 0x1;
- catflag = FALSE;
- }
- else
- {
- errmsg();
- return;
- }
- return;
- }
- else
- if((strncmp(func,band,cnt) == 0) && (cnt == 4))
- {
- bytcnt = 5;
- if(strcmp(modifier,up) == 0)
- cmd[4] = 0x6;
- else
- if(strcmp(modifier,dn) == 0)
- cmd[4] = 0x7;
- else
- {
- errmsg();
- return;
- }
- return;
- }
- else
- if((strncmp(func,split,cnt) == 0) && (cnt == 5))
- {
- bytcnt = 26;
- cmd[4] = 0xA;
- cmd[3] = 0x30;
- return;
- }
- else
- if((strncmp(func,clar,cnt) == 0) && (cnt == 4))
- {
- bytcnt = 26;
- cmd[4] = 0xA;
- cmd[3] = 0x40;
- return;
- }
- else
- if((strncmp(func,mtov,cnt) == 0) && (cnt == 4))
- {
- bytcnt = 26;
- cmd[4] = 0xA;
- cmd[3] = 0x50;
- return;
- }
- else
- if((strncmp(func,vtom,cnt) == 0) && (cnt == 4))
- {
- bytcnt = 86;
- cmd[4] = 0xA;
- cmd[3] = 0x60;
- return;
- }
- else
- if((strncmp(func,swap,cnt) == 0) && (cnt == 4))
- {
- bytcnt = 86;
- cmd[4] = 0xA;
- cmd[3] = 0x70;
- return;
- }
- else
- if((strncmp(func,prog,cnt) == 0) && (cnt == 4))
- {
- bytcnt = 5;
- for(cnt=0;cnt<=15;cnt++)
- func[cnt] = modifier[cnt];
- cnt = parse(func);
- if((strncmp(func,up,cnt) == 0) && (cnt == 2))
- {
- getnumber();
- cmd[4] = 0x4;
- cmd[3] = cmd[1];
- cmd[2] = cmd[0];
- }
- else
- if((strncmp(func,dn,cnt) == 0) && (cnt == 2))
- {
- getnumber();
- cmd[4] = 0x5;
- cmd[3] = cmd[1];
- cmd[2] = cmd[0];
- }
- else
- {
- errmsg();
- return;
- }
- return;
- }
- else
- if((strncmp(func,freq,cnt) == 0) && (cnt == 4))
- {
- bytcnt = 5;
- getnumber();
- cmd[4] = 0x8;
- return;
- }
- else
- if((strncmp(func,vfo,cnt) == 0) && (cnt == 3))
- {
- bytcnt = 5;
- cmd[4] = 0x9;
- if(strcmp(modifier,a) == 0)
- cmd[3] = 0x0;
- else
- if(strcmp(modifier,b) == 0)
- cmd[3] = 0x1;
- else
- if(strcmp(modifier,mr) == 0)
- cmd[3] = 0x2;
- else
- {
- errmsg();
- return;
- }
- return;
- }
- else
- if((strncmp(func,mem,cnt) == 0) && (cnt == 3))
- {
- bytcnt = 8;
- cmd[4] = 0xA;
- if(strcmp(modifier,m0) == 0)
- cmd[3] = 0x0;
- else
- if(strcmp(modifier,m1) == 0)
- cmd[3] = 0x1;
- else
- if(strcmp(modifier,m2) == 0)
- cmd[3] = 0x2;
- else
- if(strcmp(modifier,m3) == 0)
- cmd[3] = 0x3;
- else
- if(strcmp(modifier,m4) == 0)
- cmd[3] = 0x4;
- else
- if(strcmp(modifier,m5) == 0)
- cmd[3] = 0x5;
- else
- if(strcmp(modifier,m6) == 0)
- cmd[3] = 0x6;
- else
- if(strcmp(modifier,m7) == 0)
- cmd[3] = 0x7;
- else
- if(strcmp(modifier,m8) == 0)
- cmd[3] = 0x8;
- else
- if(strcmp(modifier,m9) == 0)
- cmd[3] = 0x9;
- else
- {
- errmsg();
- return;
- }
- return;
- }
- else
- if((strncmp(func,mode,cnt) == 0) && (cnt == 4))
- {
- bytcnt = 8;
- cmd[4] = 0xA;
- if(strcmp(modifier,lsb) == 0)
- cmd[3] = 0x10;
- else
- if(strcmp(modifier,usb) == 0)
- cmd[3] = 0x11;
- else
- if(strcmp(modifier,cw) == 0)
- cmd[3] = 0x12;
- else
- if(strcmp(modifier,am) == 0)
- cmd[3] = 0x13;
- else
- if(strcmp(modifier,fm) == 0)
- cmd[3] = 0x14;
- else
- if(strcmp(modifier,fsk) == 0)
- cmd[3] = 0x15;
- else
- {
- errmsg();
- return;
- }
- return;
- }
- else
- if((strncmp(func,ham,cnt) == 0) && (cnt == 3))
- {
- bytcnt = 26;
- cmd[4] = 0xA;
- cmd[3] = 0x20;
- return;
- }
- else
- if((strncmp(func,gen,cnt) == 0) && (cnt == 3))
- {
- bytcnt = 26;
- cmd[4] = 0xA;
- cmd[3] = 0x21;
- return;
- }
- else
- if((strncmp(func,tone,cnt) == 0) && (cnt == 4))
- {
- bytcnt = 26;
- for(cnt=0;cnt<=15;cnt++)
- func[cnt] = modifier[cnt];
- cnt = parse(func);
- if((strncmp(func,loq,cnt) == 0) && (cnt == 3))
- {
- ptr = &*lstr;
- if(cktone() == FALSE)
- {
- terr();
- return;
- }
- else
- {
- getnumber();
- cmd[4] = 0xC;
- cmd[3] = cmd[1];
- cmd[2] = cmd[0];
- cmd[1] = 0x0;
- }
- }
- else
- if((strncmp(func,hiq,cnt) == 0) && (cnt == 3))
- {
- ptr = &*hstr;
- if(cktone() == FALSE)
- {
- terr();
- return;
- }
- else
- {
- getnumber();
- cmd[4] = 0xC;
- cmd[3] = cmd[1];
- cmd[2] = cmd[0];
- cmd[1] = 0x1;
- }
- }
- else
- {
- errmsg();
- return;
- }
- return;
- }
- else
- if((strncmp(func,check,cnt) == 0) && (cnt == 5))
- {
- bytcnt = 86;
- cmd[4] = 0x1;
- return;
- }
- else
- if((strncmp(func,aclr,cnt) == 0) && (cnt == 4))
- {
- bytcnt = 26;
- cmd[4] = 0xA;
- cmd[3] = 0x80;
- return;
- }
- else
- if((strncmp(func,quit,cnt) == 0) && (cnt == 4))
- {
- bytcnt = 86;
- cmd[4] = 0x0;
- cmd[3] = 0x1;
- endprog = TRUE;
- return;
- }
- else
- if((strncmp(func,help,cnt) == 0) && (cnt == 4))
- {
- helpscreen();
- getchar();
- bytcnt = 86;
- cmd[4] = 0x1;
- return;
- }
- else
- gotoxy(0,22);
- printf(" ");
- for(cnt = 0;cnt <= 30;cnt++) putchar(8);
- printf("No such command as [ %s ]\n",func);
- clear = TRUE;
- return;
- } /*end of match*/
-
- void sendcmd()
- {
- int j,cnt;
- char echo[5];
-
- cnt = 2;
- cmd[5] = 0;
- echo[5] = 0;
-
- do
- {
- for(j = 0;j <= 4;j++)
- {
- comout(cmd[j]);
- delay();
- }
- for(j=0;j<=4;j++)
- {
- echo[j] = comin();
- delay();
- }
- --cnt;
- }
- while((cnt != 0) && (strcmp(cmd,echo) != 0)) ;
-
- if((cnt == 0) && (strcmp(cmd,echo) != 0))
- {
- gotoxy(0,22);
- printf("There was a Transmission Error\n");
- clear = TRUE;
- xmiterror = TRUE;
- return;
- }
-
- else
- {
- for(j=0;j<=4;j++) //clear cmd[j] buffer
- cmd[j] = 0;
- cmd[4] = 11; //load the acknowledgment byte
- for(j=0;j<=4;j++)
- {
- comout(cmd[j]); //send it
- delay();
- }
- loadstatus();
- }
- return;
- } /*end of sendcmd*/
-
- errmsg()
- {
- int cnt;
- gotoxy(0,22);
- printf(" ");
- for(cnt = 0;cnt <= 30;cnt++) putchar(8);
- printf("Proper Modifier Required\n");
- clear = TRUE;
- } /*end of error message*/
-
- terr()
- {
- int cnt;
- gotoxy(0,22);
- printf(" ");
- for(cnt = 0;cnt <= 30;cnt++) putchar(8);
- printf("Standard Tone Required\n");
- clear = TRUE;
- } /*end of terr message*/
-
- getnumber()
- {
- char *mod,tempbuf[9],*temp;
- int i,length;
- mod = modifier;
- temp = tempbuf;
- length = 0;
-
- while(*mod != 0)
- {
- if(isdigit(*mod) == 0) *mod++;
- else
- {
- *temp++ = *mod++;
- length++;
- }
- }
- *temp = tempbuf[length - 1];
- for(i=0;i<=length;i++)
- tempbuf[8 - i] = *temp--;
- for(i;i<=8;i++)
- tempbuf[8 - i] = '0';
- tempbuf[8] = 0;
-
- for(i=0;i<=7;i++)
- {
- tempbuf[i] = tempbuf[i] - 48; //convert characters to digits
- if(tempbuf[i] < 0) //do not allow minus digits
- tempbuf[i] = 0x0;
- }
-
- cmd[0] = tempbuf[7];
- tempbuf[6] = tempbuf[6] << 4;
- cmd[0] = cmd[0] | tempbuf[6];
- cmd[1] = tempbuf[5];
- tempbuf[4] = tempbuf[4] << 4;
- cmd[1] = cmd[1] | tempbuf[4];
- cmd[2] = tempbuf[3];
- tempbuf[2] = tempbuf[2] << 4;
- cmd[2] = cmd[2] | tempbuf[2];
- cmd[3] = tempbuf[1];
- tempbuf[0] = tempbuf[0] << 4;
- cmd[3] = cmd[3] | tempbuf[0];
- } /*end of getnumber*/
-
- loadstatus()
- {
- int k;
- int *stat;
- stat = status;
- for(k=0;k<=(bytcnt - 1);k++)
- *stat++ = comin();
- } /* end of loadstatus */
-
- gotoxy(x,y)
- int x,y;
- {
- printf("%c[%d;%dH",ESC,y,x);
- } /* end of gotoxy */
-
-
- byte1()
- {
- int k;
- k = (bytcnt - 1);
-
- if((status[k] & 0x80) != 0)
- {
- gotoxy(8,1);
- printf("CAT Control ON");
- }
- else
- {
- gotoxy(8,1);
- printf("CAT Control OFF");
- }
- if((status[k] & 0x20) != 0)
- {
- gotoxy(40,1);
- printf("Memory channel recall Active");
- }
- else
- {
- gotoxy(40,1);
- printf("Memory channel recall Inactive");
- }
- if((status[k] & 2) != 0)
- {
- gotoxy(8,2);
- printf("Ham/General Gen");
- }
- else
- {
- gotoxy(8,2);
- printf("Ham/General Ham");
- }
- if((status[k] & 4) != 0)
- {
- gotoxy(40,2);
- printf("TX Inhibit OFF");
- }
- else
- {
- gotoxy(40,2);
- printf("TX Inhibit ON");
- }
- if((status[k] & 0x10) != 0)
- {
- gotoxy(8,3);
- printf("VFO B");
- }
- else
- {
- gotoxy(8,3);
- printf("VFO A");
- }
- if((status[k] & 0x40) != 0)
- {
- gotoxy(40,3);
- printf("Clarifier ON");
- }
- else
- {
- gotoxy(40,3);
- printf("Clarifier OFF");
- }
- if((status[k] & 8) != 0)
- {
- gotoxy(8,4);
- printf("Split ON");
- }
- else
- {
- gotoxy(8,4);
- printf("Split OFF");
- }
- if((status[k] & 1) != 0)
- {
- gotoxy(40,4);
- printf("PTT Status Transmit");
- }
- else
- {
- gotoxy(40,4);
- printf("PTT Status Receive");
- }
- } /* end of byte1 */
-
- void cycles(k,x,y)
- int k,x,y;
- {
- char freq[12];
- int j,temp[3];
-
- temp[3] = status[bytcnt - k--];
- temp[2] = status[bytcnt - k--];
- temp[1] = status[bytcnt - k--];
- temp[0] = status[bytcnt - k];
-
- freq[10] = 0;
- freq[9] = temp[3];
- freq[9] = (freq[9] & 0xf) + 48;
- freq[8] = (temp[3] >> 4) + 48;
- freq[7] = '.';
- freq[6] = temp[2];
- freq[6] = (freq[6] & 0xf) + 48;
- freq[5] = (temp[2] >>4) + 48;
- freq[4] = temp[1];
- freq[4] = (freq[4] & 0xf) + 48;
- freq[3] = ',';
- freq[2] = (temp[1] >> 4) +48;
- freq[1] = temp[0];
- freq[1] = (freq[1] & 0xf) + 48;
- freq[0] = (temp[0] >> 4) + 48;
-
- if((freq[0] == '0') && (freq[1] == '0') && (freq[2] == '0'))
- freq[0] = freq[1] = freq[2] = freq[3] = ' ';
- if((freq[0] == '0') && (freq[1] == '0'))
- freq[0] = freq[1] = ' ';
- if(freq[0] == '0')
- freq[0] = ' ';
-
- gotoxy(x,y);
- printf("Frequency %s,",freq);
- return;
- } /* end of cycles */
-
- void mode(m,x,y)
- int m,x,y;
- {
- int temp;
- temp = status[bytcnt - m];
- switch(temp & 0x7)
- {
- case(0) :
- {
- gotoxy(x,y);
- printf("Mode LSB,");
- break;
- }
- case(1) :
- {
- gotoxy(x,y);
- printf("Mode USB,");
- break;
- }
- case(2) :
- {
- gotoxy(x,y);
- printf("Mode CW,");
- break;
- }
- case(3) :
- {
- gotoxy(x,y);
- printf("Mode AM,");
- break;
- }
- case(4) :
- {
- gotoxy(x,y);
- printf("Mode FM,");
- break;
- }
- case(5) :
- {
- gotoxy(x,y);
- printf("Mode FSK,");
- break;
- }
- default :
- {
- gotoxy(0,22);
- printf("mode Error\n");
- }
- }
- return;
- } /* end of mode */
-
- void display()
- {
- int byte,x,y,k;
- if(bytcnt == 86)
- CLRSCR;
-
- if(bytcnt >= 5)
- {
- byte1();
- drawline(2,5);
- gotoxy(44,6);
- putchar(' ');
- x = 2; y = 6;
- gotoxy(x,y);
- printf("Operating ");
- byte = 5; x = 13; y = 6;
- cycles(byte,x,y);
- if(bytcnt == 5)
- {
- gotoxy(0,23);
- CLREOL;
- return;
- }
- }
-
- if(bytcnt >= 8)
- {
- gotoxy(34,6);
- putchar(' ');
- byte = 7; x = 35; y = 6;
- mode(byte,x,y);
- byte = 8; x = 45; y = 6;
- memchannel(byte,x,y);
- shoband(bytcnt);
- x = 61; y = 6;
- gotoxy(x,y);
- printf(", ");
- byte = 6; x = 63; y = 6;
- ctcsstone(byte,x,y);
- if(bytcnt == 8)
- {
- gotoxy(0,23);
- CLREOL;
- return;
- }
- }
-
- if(bytcnt >= 26)
- {
- drawline(2,7);
- x = 11; y = 8;
- gotoxy(x,y);
- printf("VFO A ");
- byte = 18; x = 22; y = 8;
- cycles(byte,x,y);
- byte = 20; x = 44; y = 8;
- mode(byte,x,y);
- byte = 19; x = 54; y = 8;
- ctcsstone(byte,x,y);
- x = 11; y = 9;
- gotoxy(x,y);
- printf("VFO B ");
- byte = 24; x = 22; y = 9;
- cycles(byte,x,y);
- byte = 26; x = 44; y = 9;
- mode(byte,x,y);
- byte = 25; x = 54; y = 9;
- ctcsstone(byte,x,y);
- x = 11; y = 10;
- gotoxy(x,y);
- printf("Clarifier ");
- byte = 12; x = 22; y = 10;
- cycles(byte,x,y);
- byte = 14; x = 44; y = 10;
- mode(byte,x,y);
- byte = 13; x = 54; y = 10;
- ctcsstone(byte,x,y);
- if(bytcnt == 26)
- {
- gotoxy(0,23);
- CLREOL;
- return;
- }
- }
-
- if(bytcnt == 86)
- {
- drawline(2,11);
- for(k=0;k<=9;k++)
- {
- x = 7; y = (k + 12);
- gotoxy(x,y);
- printf("Memory Channel %d ",k);
- byte = ((k * 6) + 30); x = 25; y = (k + 12);
- cycles(byte,x,y);
- byte = ((k * 6) + 32); x = 47; y = (k + 12);
- mode(byte,x,y);
- byte = ((k * 6) + 31); x = 57; y = (k + 12);
- ctcsstone(byte,x,y);
- {
- gotoxy(0,23);
- CLREOL;
- }
- }
- }
- return;
- } /* end of display */
-
- memchannel(b,x,y)
- int b,x,y;
- {
- char temp[1];
- temp[0] = (status[bytcnt - b] + 48);
- temp[1] = 0;
- gotoxy(x,y);
- printf("Memory Channel %s",temp);
- } /* end of memchannel */
-
- ctcsstone(b,x,y)
- int b,x,y;
- {
- int tone;
- tone = (status[bytcnt - b] & 0x3f);
- gotoxy(x,y);
- printf("CTCSS Tone ");
- switch(tone)
- {
- case(0) : { puts(" 67.0"); break; }
- case(1) : { puts(" 71.9"); break; }
- case(2) : { puts(" 77.0"); break; }
- case(3) : { puts(" 82.5"); break; }
- case(4) : { puts(" 88.5"); break; }
- case(5) : { puts(" 94.8"); break; }
- case(6) : { puts(" 100.0"); break; }
- case(7) : { puts(" 103.5"); break; }
- case(8) : { puts(" 107.2"); break; }
- case(9) : { puts(" 110.9"); break; }
- case(10) : { puts(" 114.8"); break; }
- case(11) : { puts(" 118.8"); break; }
- case(12) : { puts(" 123.0"); break; }
- case(13) : { puts(" 127.3"); break; }
- case(14) : { puts(" 131.8"); break; }
- case(15) : { puts(" 136.5"); break; }
- case(16) : { puts(" 141.3"); break; }
- case(17) : { puts(" 146.2"); break; }
- case(18) : { puts(" 151.4"); break; }
- case(19) : { puts(" 156.7"); break; }
- case(20) : { puts(" 162.2"); break; }
- case(21) : { puts(" 167.9"); break; }
- case(22) : { puts(" 173.8"); break; }
- case(23) : { puts(" 179.9"); break; }
- case(24) : { puts(" 186.2"); break; }
- case(25) : { puts(" 192.8"); break; }
- case(26) : { puts(" 203.5"); break; }
- case(27) : { puts(" 210.7"); break; }
- case(28) : { puts(" 218.1"); break; }
- case(29) : { puts(" 225.7"); break; }
- case(30) : { puts(" 233.6"); break; }
- case(31) : { puts(" 241.8"); break; }
- case(32) : { puts(" 250.3"); break; }
- case(33) : { puts("C 67.0"); break; }
- case(34) : { puts("C 71.9"); break; }
- case(35) : { puts("C 74.7"); break; }
- case(36) : { puts("C 77.0"); break; }
- case(37) : { puts("C 79.7"); break; }
- case(38) : { puts("C 82.5"); break; }
- case(39) : { puts("C 85.4"); break; }
- case(40) : { puts("C 88.5"); break; }
- case(41) : { puts("C 91.5"); break; }
- default :
- {
- gotoxy(0,22);
- printf("Where did it get that tone?");
- }
- }
- } /* end of ctcsstone */
-
- isin(tone)
- char *tone;
- {
- int index;
-
- if(strlen(tone) == 0)
- return(FALSE);
- else
- {
- index = -1;
- do
- {
- if(! strcmp(tone,ptr[++index]))
- return(1);
- }
- while(strcmp(EDTB,ptr[index]));
- return(0);
- }
- } /* end of isin() */
-
- cktone()
- {
- char buf[8];
- int i;
- i = 0;
- while(modifier[i] != 0)
- {
- buf[i] = modifier[i];
- i++;
- }
- buf[i] = 0;
- if(isin(&buf) == FALSE) return(FALSE);
- else
- if(isin(&buf) == TRUE) return(TRUE);
- } /* end of cktone() */
-
- drawline(x,y)
- int x,y;
- {
- int i;
- gotoxy(x,y);
- for(i=0;i<=77;i++)
- putchar(0xC4);
- } /* end of drawline */
-
- shoband()
- {
- int band;
- band = status[bytcnt - 7];
- band = (band & 120);
- band = (band >> 3);
- if(status[bytcnt - 2] >= 0x44) band = 15;
- gotoxy(40,22);
- printf("Band = ");
- switch(band)
- {
- case(1) : { printf(" 1,500.00 MHZ - 2,499.99 MHZ"); break; }
- case(2) : { printf(" 2,500.00 MHZ - 3,999.99 MHZ"); break; }
- case(3) : { printf(" 4,000.00 MHZ - 7,499.99 MHZ"); break; }
- case(4) : { printf(" 7,500.00 MHZ - 10,499.99 MHZ"); break; }
- case(5) : { printf(" 10,500.00 MHZ - 14,499.99 MHZ"); break; }
- case(6) : { printf(" 14,500.00 MHZ - 18,499.99 MHZ"); break; }
- case(7) : { printf(" 18,500.00 MHZ - 21,499.99 MHZ"); break; }
- case(8) : { printf(" 21,500.00 MHZ - 24,999.99 MHZ"); break; }
- case(9) : { printf(" 25,000.00 MHZ - 29,999.99 MHZ"); break; }
- case(10) : { printf(" 50,000.00 MHZ - 59,999.99 MHZ"); break; }
- case(11) : { printf("144,000.00 MHZ - 149,999.99 MHZ"); break; }
- case(12) : { printf("430,000.00 MHZ - 439,999.99 MHZ"); break; }
- case(13) : { printf(" 000.00 MHZ - 499.99 MHZ"); break; }
- case(14) : { printf(" 500.00 MHZ - 1,499.99 MHZ"); break; }
- case(15) : { printf("440,000.00 MHZ - 449,999.99 MHZ"); break; }
- default : { printf("Frequency outside of Range"); break; }
- }
- } /* end of shoband */
-
- helpscreen()
- {
- CLRSCR;
- printf("COMMAND & MODIFIERS if ANY FUNCTION\n");
- printf("check\t\t\t\tGet the status of functions, and redraw screen\n");
- printf("gen\t\t\t\tGeneral coverage receiver\n");
- printf("ham\t\t\t\tAmateur bands only\n");
- printf("quit\t\t\t\tTurn CAT off and terminate program\n");
- printf("up\t\t\t\tTune up 10hz\n");
- printf("dn\t\t\t\tTune down 10hz\n");
- printf("prog\tup/dn & amount\t\tTune Up/Down 00 00 to 99 99 or 0-99.99khz\n");
- printf("band\tup/dn\t\t\tStep Up/Down one ham band or .5 Mhz in Gen\n");
- printf("freq\t(actual)\t\tTune to entered Frequency\n");
- printf("vfo\ta/b/mr\t\t\tVFO/Memory select\n");
- printf("mem\tm(0,1,2,3,4,5,6,7,8,9)\tMemory select\n");
- printf("mode\tlsb/usb/cw/am/fm/fsk\tMode select\n");
- printf("split\t\t\t\tToggle split Frequency operation on/off\n");
- printf("clar\t\t\t\tToggle Clarifier on/off\n");
- printf("mtov\t\t\t\tMemory to VFO\n");
- printf("vtom\t\t\t\tVFO to Memory\n");
- printf("swap\t\t\t\tSwap VFO and Memory\n");
- printf("aclr\t\t\t\tTurn off Split, Clar and Offset\n");
- printf("tone loq/hiq ctcss frequency\tSet CTCSS TONE\n");
- printf("help\t\t\t\tThis display\n");
- printf("diskmem\t\t\t\tStore or Recall in or from disk Memory\n");
- printf("\t\tPress Enter to return to the control program --- ");
- } /* end of helpscreen */
-
- /*initialize com port ( in this case com2)*/
- /*done in assembler for simplicity*/
- initcom()
- {
- __asm
- {
- mov ah,0
- mov dx,1 //0 for com1, 1 for com2
- mov al,11000111b //4800 baud, 2 stop bits
- //8 data bits, no parity
- int 14h
- }
- } /*end of initcom*/
-
- delay()
- {
- int cnt;
- /*define the value of FACTOR low, even 0 for slow machines*/
- /*such as 286 @ 8 mhz, 800 works on my 486 @ 66 or @ 33 mhz*/
- for(cnt = 0;cnt <= FACTOR;cnt++) ;
- } /*end of delay*/
-
- comin()
- {
- int j;
- unsigned char ch;
- j = TIMEOUT;
- while((_inp(0x2fd) & 0x01) == 0)
- {
- --j;
- if(j == 0)
- break;
- }
- if(j == 0)
- ch = 0;
- else
- ch = (_inp(0x2f8));
- return(ch);
- } /*end of comin*/
-
- comout(ch)
- char ch;
- {
- while((_inp(0x2fd) & 0x20) == 0) ;
- _outp(0x2f8,ch);
- } /*end of comout*/
-
- testport()
- {
- int j;
- j = TIMEOUT;
- while( (_inp(0x2fe) & 0x30) == 0)
- {
- --j;
- if(j == 0) return(0xff);
- }
- return(0);
- } /*end of testport*/
-
- startup()
- {
- char func[5],*edit;
- edit = "edit";
- helpscreen();
- gotoxy(0,23);
- CLREOL;
- printf("edit\t Enter edit now to edit disk memory files or\n");
- printf("\t Press Enter to proceed to the control program --- ");
- gets(func);
- if(strlen(func) == 0) ;
- else
- if(strncmp(func,edit,4) == 0)
- edit_control();
- CLRSCR;
- initcom();
-
- if(testport() != 0)
- {
- gotoxy(10,10);
- printf("Check the cable connections and turn on the interface device.\n");
- gotoxy(0,23);
- exit(0);
- }
- bytcnt = 86;
- cmd[3] = 0x0;
- cmd[4] = 0x0;
- sendcmd();
- catflag = TRUE; //the FT-767GX CAT function has been turned on
- display();
- } /*end of startup*/
-
- is_ansi()
- {
- FILE *fp,*fopen();
- char ch,buffer[80],*ptr;
- char drive,file[15] = "0:\\config.sys";
- int flag;
-
- _asm {
- mov ax,3305h
- int 21h
- mov drive,dl
- }
-
- file[0] = (drive + 64);
- if((fp = fopen(file,"r")) == NULL)
- {
- printf("File %s did not open.\n",file);
- exit(0);
- }
-
- flag = 0;
- ptr = buffer;
- memset(ptr,0,80);
- while((ch = getc(fp)) != EOF)
- {
- *ptr++ = tolower(ch);
- if(ch == '\n')
- {
- if((strstr(buffer,"ansi.sys")) != 0)
- {
- flag = 1;
- break;
- }
- else
- {
- ptr = buffer;
- memset(ptr,0,80);
- }
- }
- }
- fclose(fp);
- if(flag == 0)
- {
- system("cls");
- printf("\n\n\n\n\n\n\n\n");
- printf("\tSome commands from the ANSI.SYS driver are required by this\n");
- printf("\tprogram. The driver does not appear to be in the boot disk's\n");
- printf("\tCONFIG.SYS file.\n\n");
- printf("\tPlease add a line such as DEVICE=C:\\DOS\\ANSI.SYS to the\n");
- printf("\tCONFIG.SYS file and reboot the system.\n");
- printf("\n\n\n\n\n\n\n");
- exit(0);
- }
- } /* end of is_ansi */
-
- main()
- {
- char func[15],*caton,*catoff,*recall,*diskmem;
- int i,k;
- endprog = FALSE;
- catflag = FALSE;
- caton = "cat on";
- catoff = "cat off";
- diskmem = "diskmem";
-
- is_ansi();
- startup();
- for(;;)
- {
- clear = FALSE;
- xmiterror = FALSE;
- for(i=0;i<=15;i++)
- func[i] = 0;
- for(i=0;i<=10;i++)
- cmd[i] = 0;
- bytcnt = 0;
- gotoxy(0,23);
- putchar('>');
- CLREOL;
-
- gets(func);
- if((strncmp(func,catoff,6) == 0) && (catflag == TRUE)) ;
- else
- if((strncmp(func,caton,5) == 0) && (catflag == TRUE)) ;
- else
- if(strlen(func) == 0) ;
- else
- if((strncmp(func,diskmem,7) == 0))
- {
- disk_memory_control();
- do_it("check");
- display();
- }
- else
- {
- gotoxy(0,22);
- printf(" \n");
- match(func,parse(func));
- if(clear == FALSE)
- {
- sendcmd();
- if(xmiterror == TRUE) ;
- else
- display();
- }
- }
- if(endprog == TRUE) break;
- }
- } /*end of main*/
-
-
- void disk_memory_control(void)
- {
- int option;
- do
- {
- clrscr();
- printf("\t\t\tAccess to extra memories on disk\n\n");
- printf("\t\t\t General Coverage Reception and\n");
- printf("\t\t\t Amateur Band Simplex operation\n\n");
- printf("\t 1 - Store VFO A to General Disk Memory\n");
- printf("\t 2 - Recall General Disk Memory to VFO A\n");
- printf("\t 3 - View the General Stations file\n");
- printf("\t 4 - Add Stations to General Coverage disk memory by hand\n");
- printf("\t 5 - Remove Stations from General Coverage disk memory\n");
- printf("\n\t\t\t Amateur Band Split Frequency\n");
- printf("\t\t\t and Repeater Operation\n\n");
- printf("\t 6 - Store VFOs to Amateur Band Repeater Disk Memory\n");
- printf("\t 7 - Recall Amateur Band Repeater Disk Memory to VFOs\n");
- printf("\t 8 - View the Amateur Band Repeater Stations file\n");
- printf("\t 9 - Add Stations to Amateur Repeater disk memory by hand\n");
- printf("\t 10 - Remove Stations from Amateur Repeater disk memory\n");
- printf("\n\t 11 - To return to main program\n\n");
- printf("\t Enter selection --- ");
- scanf("%d",&option);
- fflush(stdin);
- }
- while((option < 1) || (option > 11));
- selection(option);
- } /*end of disk_memory_control*/
-
- int selection(int choice)
- {
- switch(choice)
- {
- case 1: store(1); break;
- case 2: recall(2); break;
- case 3: examine_files(3); break;
- case 4: add_station(4); break;
- case 5: delete_station(5); break;
- case 6: store(6); break;
- case 7: recall(7); break;
- case 8: examine_files(8); break;
- case 9: add_station(9); break;
- case 10: delete_station(10); break;
- default: return(0);
- }
- } /*end of selection*/
-
- void store(int num)
- {
- int k;
- clrscr();
- do_it("check");
- k = (bytcnt - 1);
- if((status[k] & 0x10) != 0)
- {
- gotoxy(28,10);
- printf("VFO B is the active VFO");
- }
- else
- {
- gotoxy(28,10);
- printf("VFO A is the active VFO");
- }
- gotoxy(22,23);
- printf("Press Enter to contiue, ESC to abort");
- if(_getch() == ESC) return;
- if((num == 1) || (num == 6))
- add_station(num);
- } /*end of store*/
-
- void examine_files(int num)
- {
- int record_cnt;
-
- record_cnt = loadfile(num);
- if(record_cnt != -3)
- viewfile(record_cnt,num);
- } /*end of examine_files*/
-
- int add_station(int num)
- {
- int record_cnt;
-
- for(;;)
- {
- record_cnt = loadfile(num);
- if(record_cnt > -2)
- {
- if(num < 6)
- {
- if(gen_insert(record_cnt,num) == 1)
- viewfile((record_cnt + 1),num);
- }
- if(num >= 6)
-
- {
- if(rep_insert(record_cnt,num) == 1)
- viewfile((record_cnt + 1),num);
- }
- }
- else
- if(record_cnt == -4)
- {
- record_cnt = -1;
- if(num < 6)
- {
- if(gen_insert(record_cnt,num) == 1)
- viewfile((record_cnt + 1),num);
- }
- if(num >= 6)
- {
- if(rep_insert(record_cnt,num) == 1)
- viewfile((record_cnt + 1),num);
- }
- }
- else
- if(record_cnt == -3) break;
- clrscr();
- if((num == 1) || (num == 6)) break;
- gotoxy(0,10);
- printf("\n\n\t\tAdd another station? y or n --- ");
- if(getreply() == 1) break;
- }
- } /*end of add_station*/
-
- int delete_station(int num)
- {
- int record_cnt,del_rec;
-
- for(;;)
- {
- record_cnt = loadfile(num);
- if(record_cnt == -3) break;
- do
- {
- viewfile(record_cnt,num);
- gotoxy(0,24);
- CLREOL;
- gotoxy(13,24);
- printf("Enter the MEM number of the station to be removed --- ");
- scanf("%d",&del_rec);
- }
- while((del_rec < 1) || (del_rec > (record_cnt + 1)));
-
- if((del_rec == 1) && (record_cnt == 0))
- {
- if(num < 6)
- system("del general.dat");
- if(num > 6)
- system("del repeater.dat");
- }
- else
- {
- remove_record(del_rec,record_cnt,num);
- savedata(record_cnt - 1,num);
- clrscr();
- gotoxy(0,10);
- printf("\n\n\t\tRemove another station? y or n --- ");
- if(getreply() == 1) break;
- }
- }
- } /*end of delete_station*/
-
- int getreply(void)
- {
- char ch;
- #undef toupper
- do
- {
- ch = toupper(_getch());
- } while((ch != 'Y') && (ch != 'N'));
- if(ch == 'Y') return(0);
- else
- if(ch == 'N') return(1);
- } /*end of getreply*/
-
- void backup(int spaces)
- {
- int i;
- for(i = 0;i <= spaces;++i) BACKSPACE;
- } /*end of backup*/
-
- int gen_insert(int rcnt , int num)
- {
- int len,recnum;
- struct general *pt1,*pt2;
- if(num == 4)
- input_data(4);
- else
- if(num == 1)
- get_data(1);
- for(recnum = 0;recnum <= rcnt;++recnum)
- {
- if(atol(gentemp.freq) < atol(g[recnum].freq))
- break;
- else
- if(atol(gentemp.freq) == atol(g[recnum].freq))
- {
- printf("\n\n\n\n\t\t\tA station is in the list at %s\n",g[recnum].freq);
- printf("\n\t\t\tPress any key to continue --- ");
- _getch();
- return(0);
- }
- else
- if(atol(gentemp.freq) > atol(g[recnum].freq))
- ;
- }
- sprintf(gentemp.rec,"%d",(recnum));
- len = sizeof(struct general);
- if(recnum > rcnt)
- {
- pt1 = &gentemp;
- pt2 = &g[recnum];
- memcpy(pt2,pt1,len);
- }
- else
- {
- pt1 = &g[recnum + 1];
- pt2 = &g[recnum];
- memmove(pt1,pt2,(rcnt + 1 - recnum) * len);
- pt1 = &gentemp;
- pt2 = &g[recnum];
- memcpy(pt2,pt1,len);
- }
- reindex(rcnt,num,1);
- savedata(rcnt + 1,num);
- return(1);
- } /*end of gen_insert*/
-
- int loadfile(int num)
- {
- FILE *fp,*fopen();
- int i;
- char buff[40],*p1,*p2;
-
- if(num < 6)
- {
- if((fp=fopen("general.dat","r")) == 0)
- {
- clrscr();
- printf("\n\n\n\n\n\n");
- printf("\t\tFile GENERAL.DAT does not exist.\n");
- if((num == 2) || (num == 3) || (num == 5))
- {
- press_enter(90,24);
- return(-3);
- }
- else
- {
- printf("\t\tShould I create a new file? y or n --- ");
- i = getreply();
- if(i == 1) return(-3);
- if(i == 0) return(-4);
- }
- }
- }
-
- if(num >= 6)
- {
- if((fp=fopen("repeater.dat","r")) == 0)
- {
- clrscr();
- printf("\n\n\n\n\n\n");
- printf("\t\tFile REPEATER.DAT does not exist.\n");
- if((num == 7) || (num == 8) || (num == 10))
- {
- press_enter(90,24);
- return(-3);
- }
- else
- {
- printf("\t\tShould I create a new file? y or n --- ");
- i = getreply();
- if(i == 1) return(-3);
- if(i == 0) return(-4);
- }
- }
- }
- i = 0;
- while(!feof(fp))
- {
- p1 = buff;
- if(num < 6)
- p2 = g[i].rec;
- if(num >= 6)
- p2 = r[i].rec;
- fgets(p1,5,fp);
- while(*p1 != '\n')
- *p2++ = *p1++;
-
- if(num < 6)
- {
- p1 = buff;
- p2 = g[i].freq;
- fgets(p1,10,fp);
- while(*p1 != '\n')
- *p2++ = *p1++;
- }
-
- if(num >= 6)
- {
- p1 = buff;
- p2 = r[i].afreq;
- fgets(p1,10,fp);
- while(*p1 != '\n')
- *p2++ = *p1++;
-
- p1 = buff;
- p2 = r[i].bfreq;
- fgets(p1,10,fp);
- while(*p1 != '\n')
- *p2++ = *p1++;
- }
-
- p1 = buff;
- if(num < 6)
- p2 = g[i].mode;
- if(num >= 6)
- p2 = r[i].mode;
- fgets(p1,5,fp);
- while(*p1 != '\n')
- *p2++ = *p1++;
-
- if(num < 6) ;
- if(num >= 6)
- {
- p1 = buff;
- p2 = r[i].tone;
- fgets(p1,9,fp);
- while(*p1 != '\n')
- *p2++ = *p1++;
- }
-
- p1 = buff;
- if(num < 6)
- p2 = g[i].call;
- if(num >= 6)
- p2 = r[i].call;
- fgets(p1,10,fp);
- while(*p1 != '\n')
- *p2++ = *p1++;
-
- p1 = buff;
- if(num < 6)
- p2 = g[i].loc;
- if(num >= 6)
- p2 = r[i].loc;
- fgets(p1,36,fp);
- while(*p1 != '\n')
- *p2++ = *p1++;
- ++i;
- }
- fclose(fp);
- return(i - 2);
- } /*end of loadfile*/
-
- int rep_insert(int rcnt , int num)
- {
- int len,recnum;
- struct repeater *pt1,*pt2;
- if(num == 9)
- input_data(9);
- else
- if(num == 6)
- get_data(6);
- for(recnum = 0;recnum <= rcnt;++recnum)
- {
- if(atol(reptemp.afreq) < atol(r[recnum].afreq))
- break;
- else
- if(atol(reptemp.afreq) == atol(r[recnum].afreq))
- {
- printf("\n\n\n\n\t\t\tA station is in the list at %s\n",r[recnum].afreq);
- printf("\n\t\t\tPress any key to continue --- ");
- _getch();
- return(0);
- }
- else
- if(atol(reptemp.afreq) > atol(r[recnum].afreq))
- ;
- }
- sprintf(reptemp.rec,"%d",(recnum));
- len = sizeof(struct repeater);
- if(recnum > rcnt)
- {
- pt1 = &reptemp;
- pt2 = &r[recnum];
- memcpy(pt2,pt1,len);
- }
- else
- {
- pt1 = &r[recnum + 1];
- pt2 = &r[recnum];
- memmove(pt1,pt2,(rcnt + 1 - recnum) * len);
- pt1 = &reptemp;
- pt2 = &r[recnum];
- memcpy(pt2,pt1,len);
- }
- reindex(rcnt,num,1);
- savedata(rcnt + 1,num);
- return(1);
- } /*end of rep_insert*/
-
- int savedata(int maxcnt, int num)
- {
- FILE *fp,*fopen();
- int i;
- if(maxcnt < 0)
- return(0);
-
- if(num < 6)
- {
- if((fp=fopen("general.dat","w")) == 0)
- {
- clrscr();
- printf("\n\n\n\n\n\n\n\t\t\tFile GENERAL.DAT Open Failed\n\n\n");
- if((fp=fopen("general.dat","r")) != 0)
- {
- printf("\t\tWrite protected disk.\n\n");
- fclose(fp);
- }
- return(0);
- }
- }
-
- if(num >= 6)
- {
- if((fp=fopen("repeater.dat","w")) == 0)
- {
- clrscr();
- printf("\n\n\n\n\n\n\n\t\t\tFile REPEATER.DAT Open Failed\n\n\n");
- if((fp=fopen("repeater.dat","r")) != 0)
- {
- printf("\t\tWrite protected disk.\n\n");
- fclose(fp);
- }
- return(0);
- }
- }
-
- if(num < 6)
- {
- for(i = 0;i <= maxcnt; ++i)
- {
- fprintf(fp,"%s\n",g[i].rec);
- fprintf(fp,"%s\n",g[i].freq);
- fprintf(fp,"%s\n",g[i].mode);
- fprintf(fp,"%s\n",g[i].call);
- fprintf(fp,"%s\n",g[i].loc);
- }
- fclose(fp);
- return(0);
- }
-
- if(num >= 6)
- {
- for(i = 0;i <= maxcnt; ++i)
- {
- fprintf(fp,"%s\n",r[i].rec);
- fprintf(fp,"%s\n",r[i].afreq);
- fprintf(fp,"%s\n",r[i].bfreq);
- fprintf(fp,"%s\n",r[i].mode);
- fprintf(fp,"%s\n",r[i].tone);
- fprintf(fp,"%s\n",r[i].call);
- fprintf(fp,"%s\n",r[i].loc);
- }
- fclose(fp);
- return(0);
- }
- } /*end of savedata*/
-
- void input_data(int num)
- {
- char buf[42],*p1,*p2;
- #undef toupper
- if(num == 4)
- memset(&gentemp,0,sizeof(struct general) + 1);
- if(num == 9)
- memset(&reptemp,0,sizeof(struct repeater) + 1);
- clrscr();
- printf("\n\n\n");
- while(TRUE)
- {
- if(num == 4)
- {
- printf("Enter Station's Frequency ________");
- backup(7);
- gets(gentemp.freq);
- if(strlen(gentemp.freq) <= 8 && strlen(gentemp.freq) > 0) break;
- }
- if(num == 9)
- {
- printf("Enter Station's VFO A Frequency ________");
- backup(7);
- gets(reptemp.afreq);
- if(strlen(reptemp.afreq) <= 8 && strlen(reptemp.afreq) > 0) break;
- }
- }
- if(num == 4) ;
- else
- if(num == 9)
- {
- while(TRUE)
- {
- printf("Enter Station's VFO B Frequency ________");
- backup(7);
- if(num == 9)
- gets(reptemp.bfreq);
- if(strlen(reptemp.bfreq) <= 8 && strlen(reptemp.bfreq) > 0) break;
- }
- }
-
- while(TRUE)
- {
- printf("Enter Station's Mode ___");
- backup(2);
- p1 = buf;
- if(num == 4)
- p2 = gentemp.mode;
- if(num == 9)
- p2 = reptemp.mode;
- gets(buf);
- if(strlen(buf) <= 3 && strlen(buf) > 0) break;
- }
- while(*p1 != 0)
- *p2++ = toupper(*p1++);
- *p2 = 0;
-
- if(num == 4) ;
- else
- {
- if(num == 9)
- {
- while(TRUE)
- {
- printf("Enter Station's CTCSS TONE _______");
- backup(6);
- p1 = buf;
- p2 = reptemp.tone;
- gets(buf);
- if(strlen(buf) <= 7 && strlen(buf) > 0) break;
- }
- while(*p1 != 0)
- {
- if(isalpha(*p1) != 0)
- *p2++ = toupper(*p1++);
- else
- *p2++ = *p1++;
- }
- }
- }
-
- while(TRUE)
- {
- printf("Enter Station's Call Letters ________");
- backup(7);
- p1 = buf;
- if(num == 4)
- p2 = gentemp.call;
- if(num == 9)
- p2 = reptemp.call;
- gets(buf);
- if(strlen(buf) <= 8 && strlen(buf) > 0) break;
- }
- while(*p1 != 0)
- {
- if(isalpha(*p1) != 0)
- *p2++ = toupper(*p1++);
- else
- *p2++ = *p1++;
- }
-
- while(TRUE)
- {
- printf("Enter Station's Location __________________________________");
- backup(33);
- p1 = buf;
- if(num == 4)
- p2 = gentemp.loc;
- if(num == 9)
- p2 = reptemp.loc;
- gets(buf);
- if(strlen(buf) <= 34 && strlen(buf) > 0) break;
- }
- while(*p1 != 0)
- *p2++ = toupper(*p1++);
- *p2 = 0;
- } /*end of input_data*/
-
- void remove_record(int del , int cnt , int num)
- {
- int i,j,len,dest;
- dest = (del - 1);
- if(num < 6)
- {
- len = sizeof(struct general);
- ptg1 = &g[dest];
- ptg2 = &g[del];
- memmove(ptg1,ptg2,((cnt + 2) - del)*(len));
- }
- if(num > 6)
- {
- len = sizeof(struct repeater);
- ptr1 = &r[dest];
- ptr2 = &r[del];
- memmove(ptr1,ptr2,((cnt + 2) - del)*(len));
- }
- reindex(cnt,num,0);
- } /*end of remove_record*/
-
- void reindex(int cnt , int num , int j)
- {
- int i;
- for(i = 0;i <= (cnt + j); ++i)
- {
- if(num < 6)
- sprintf(g[i].rec,"%d",(i + 1));
- if(num >= 6)
- sprintf(r[i].rec,"%d",(i + 1));
- }
- } /*end of reindex*/
-
- void viewfile(int cnt , int num)
- {
- int i;
- char buff[12],ch;
-
- clrscr();
- if( num < 6)
- {
- printf("MEM Frequency Mode Call\t Location & Comments\n\n");
- }
- else
- {
- printf("MEM Frequency Mode CTCSS Call Location & Comments\n");
- }
- for(i = 0;i <= cnt; ++i)
- {
- if(num < 6)
- {
- convert(buff,g[i].freq);
- printf("%-3s %10s %-3s %-8s %-34s\n",g[i].rec,buff,
- g[i].mode,g[i].call,g[i].loc);
- }
- else
- {
- convert(buff,r[i].afreq);
- printf("%-3s A %10s %-3s %7s %-8s %-34s\n",r[i].rec,buff,
- r[i].mode,r[i].tone,r[i].call,r[i].loc);
- convert(buff,r[i].bfreq);
- printf(" B %10s %-3s %7s %-8s %-34s\n",buff,
- r[i].mode,r[i].tone,r[i].call,r[i].loc);
- }
- if(num < 6)
- {
- if(((i + 1) % 20) == 0 && (i > 0) && (i < cnt))
- {
- if((num == 2) || (num == 5))
- {
- gotoxy(14,24);
- printf("Press ESC to stop paging or any other key for next page --- ");
- if((ch = _getch()) == ESC)
- break;
- }
- else
- press_enter(91,24);
- clrscr();
- printf("MEM Frequency Mode Call\t Location & Comments\n\n");
- }
- }
- else
- {
- if(((i + 1) % 10) == 0 && (i > 0) && (i < cnt))
- {
- if((num == 7) || (num == 10))
- {
- gotoxy(14,24);
- printf("Press ESC to stop paging or any other key for next page --- ");
- if((ch = _getch()) == ESC)
- break;
- }
- else
- press_enter(91,24);
- clrscr();
- printf("MEM Frequency Mode CTCSS Call Location & Comments\n");
- }
- }
- }
- if(ch != ESC)
- press_enter(90,24);
- } /*end of viewfile*/
-
- void press_enter(int x, int y)
- {
- if(x == 90)
- {
- gotoxy(0,y);
- printf("\t\t End of file Press ENTER to continue --- ");
- }
- else
- if(x == 91)
- {
- gotoxy(0,y);
- printf("\t\t Press ENTER to continue to the next page --- ");
- }
- else
- {
- gotoxy(x,y);
- printf("Press ENTER to continue --- ");
- }
- while(_getch() != '\r')
- gotoxy(61,y);
- } /*end of press_enter*/
-
- char *convert(char *buff , char *freq)
- {
- int i,l;
- char first[10];
- char second[12];
-
- memset(first,0,10);
- memset(second,0,12);
- memcpy(first,freq,strlen(freq));
- l = strlen(first);
- second[10] = first[l];
- second[9] = first[l - 1];
- second[8] = first[l - 2];
- second[7] = '.';
- second[6] = first[l - 3];
- second[5] = first[l - 4];
- second[4] = first[l - 5];
- if(l > 5)
- second[3] = ',';
- else second[3] = ' ';
- if(l >= 6)
- second[2] = first[l - 6];
- else second[2] = ' ';
- if(l >= 7)
- second[1] = first[l - 7];
- else second[1] = ' ';
- if(l >= 8)
- second[0] = first[l - 8];
- else second[0] = ' ';
- for(i = 0;i <= strlen(second);i++)
- *(buff + i) = second[i];
- return(buff);
- } /*end of convert*/
-
- void recall(int num)
- {
- int k;
- char fbuf[15],mbuf[8],freq[5] = "freq ",mode[5] = "mode ";
- char *loq,*hiq,*p1,*p2,buff[5];
- char tonebuf[18],loqtone[9] = "tone loq ",hiqtone[9] = "tone hiq ";
-
- clrscr();
- gotoxy(15,8);
- printf("If you know the MEM number of the station you want");
- gotoxy(34,10);
- printf("Enter it now,");
- gotoxy(19,12);
- printf("or Enter a 0 to view the station list --- ");
- gotoxy(15,14);
- printf("Examine the contents of the Data File and take note\n");
- gotoxy(15,16);
- printf("of the MEM number of the station you wish to recall.");
- gotoxy(25,18);
- printf("Enter it when directed to do so.");
- gotoxy(61,12);
- scanf("%d",&k);
- clrscr();
-
- if(loadfile(num) == -3)
- return;
-
- if(k == 0)
- {
- examine_files(num);
- gotoxy(0,24);
- CLREOL;
- gotoxy(23,24);
- printf("Enter the selected MEM number --- ");
- scanf("%i",&k);
- k--;
- }
- else
- {
- loadfile(num);
- k--;
- }
-
- #undef tolower
- if(num < 6)
- {
- do_it("aclr");
- do_it("gen");
- do_it("vfo a");
-
- memcpy(fbuf,freq,5);
- memcpy(fbuf + 5,g[k].freq,strlen(g[k].freq) + 1);
- do_it(fbuf);
-
- p1 = g[k].mode;
- p2 = buff;
- while(*p1 != 0)
- *p2++ = tolower(*p1++);
- *p2 = 0;
- memcpy(mbuf,mode,5);
- memcpy(mbuf + 5,buff,strlen(buff) + 1);
- do_it(mbuf);
- }
- else
- {
- do_it("aclr");
- do_it("ham");
-
- do_it("vfo b");
- memcpy(fbuf,freq,5);
- memcpy(fbuf + 5,r[k].bfreq,strlen(r[k].bfreq) + 1);
- do_it(fbuf);
-
- p1 = r[k].mode;
- p2 = buff;
- while(*p1 != 0)
- *p2++ = tolower(*p1++);
- *p2 = 0;
- memcpy(mbuf,mode,5);
- memcpy(mbuf + 5,buff,strlen(buff) + 1);
- do_it(mbuf);
-
- if(r[k].tone[0] == 'C')
- {
- hiq = r[k].tone;
- while(isdigit(*hiq) == 0) hiq++;
- memcpy(tonebuf,hiqtone,9);
- memcpy(tonebuf + 9,hiq,strlen(r[k].tone) - 1);
- do_it(tonebuf);
- }
- else
- {
- loq = r[k].tone;
- while(isdigit(*loq) == 0) loq++;
- memcpy(tonebuf,loqtone,9);
- memcpy(tonebuf + 9,loq,strlen(r[k].tone) + 1);
- do_it(tonebuf);
- }
- do_it("vfo a");
- memcpy(fbuf,freq,5);
- memcpy(fbuf + 5,r[k].afreq,strlen(r[k].afreq) + 1);
- do_it(fbuf);
-
- p1 = r[k].mode;
- p2 = buff;
- while(*p1 != 0)
- *p2++ = tolower(*p1++);
- *p2 = 0;
- memcpy(mbuf,mode,5);
- memcpy(mbuf + 5,buff,strlen(buff) + 1);
- do_it(mbuf);
-
- if(r[k].tone[0] == 'C')
- {
- hiq = r[k].tone;
- while(isdigit(*hiq) == 0) hiq++;
- memcpy(tonebuf,hiqtone,9);
- memcpy(tonebuf + 9,hiq,strlen(r[k].tone) - 1);
- do_it(tonebuf);
- }
- else
- {
- loq = r[k].tone;
- while(isdigit(*loq) == 0) loq++;
- memcpy(tonebuf,loqtone,9);
- memcpy(tonebuf + 9,loq,strlen(r[k].tone) + 1);
- do_it(tonebuf);
- }
- do_it("split on");
- }
- } /*end of recall*/
-
- void do_it(char *func)
- {
- int cnt;
- match(func,parse(func));
- sendcmd();
- for(cnt = 0;cnt <= 18000;cnt++);
- } /*end of do_it*/
-
- char *hertz(char *buffer, int k)
- {
- char freq[12];
- int j,temp[3];
-
- temp[3] = status[bytcnt - k--];
- temp[2] = status[bytcnt - k--];
- temp[1] = status[bytcnt - k--];
- temp[0] = status[bytcnt - k];
-
- freq[8] = 0;
- freq[7] = temp[3];
- freq[7] = (freq[7] & 0xf) + 48;
- freq[6] = (temp[3] >> 4) + 48;
- freq[5] = temp[2];
- freq[5] = (freq[5] & 0xf) + 48;
- freq[4] = (temp[2] >>4) + 48;
- freq[3] = temp[1];
- freq[3] = (freq[3] & 0xf) + 48;
- freq[2] = (temp[1] >> 4) +48;
- freq[1] = temp[0];
- freq[1] = (freq[1] & 0xf) + 48;
- freq[0] = (temp[0] >> 4) + 48;
-
- if((freq[0] == '0') && (freq[1] == '0') && (freq[2] == '0'))
- freq[0] = freq[1] = freq[2] = ' ';
- if((freq[0] == '0') && (freq[1] == '0'))
- freq[0] = freq[1] = ' ';
- if(freq[0] == '0')
- freq[0] = ' ';
- for(j = 0;j <= strlen(freq);j++)
- *(buffer + j) = freq[j];
- return(buffer);
- } /* end of hertz */
-
- void vfo_mode(int m)
- {
- int temp;
- char mbuff[5],*p1,*p2;
- p1 = mbuff;
- temp = status[bytcnt - m];
- switch(temp & 0x7)
- {
- case(0) : p1 = "LSB"; break;
- case(1) : p1 = "USB"; break;
- case(2) : p1 = "CW"; break;
- case(3) : p1 = "AM"; break;
- case(4) : p1 = "FM"; break;
- case(5) : p1 = "FSK"; break;
- }
- if(m == 7)
- p2 = gentemp.mode;
- else
- if(m == 20)
- p2 = reptemp.mode;
- while(*p1 != 0)
- *p2++ = *p1++;
- *p2 = 0;
- } /*end of vfo_mode*/
-
- void get_data(int num)
- {
- char buf[42],*p1,*p2;
- #undef toupper
- if(num == 1)
- memset(&gentemp,0,sizeof(struct general) + 1);
- if(num == 6)
- memset(&reptemp,0,sizeof(struct repeater) + 1);
- clrscr();
- printf("\n\n\n");
- if(num == 1)
- {
- hertz(gentemp.freq,5);
- vfo_mode(7);
- }
- if(num == 6)
- {
- hertz(reptemp.afreq,18);
- vfo_mode(20);
- hertz(reptemp.bfreq,24);
- pl_tone(25);
- }
- while(TRUE)
- {
- printf("Enter Station's Call Letters ________");
- backup(7);
- p1 = buf;
- if(num == 1)
- p2 = gentemp.call;
- if(num == 6)
- p2 = reptemp.call;
- gets(buf);
- if(strlen(buf) <= 8 && strlen(buf) > 0) break;
- }
- while(*p1 != 0)
- {
- if(isalpha(*p1) != 0)
- *p2++ = toupper(*p1++);
- else
- *p2++ = *p1++;
- }
- while(TRUE)
- {
- printf("Enter Station's Location __________________________________");
- backup(33);
- p1 = buf;
- if(num == 1)
- p2 = gentemp.loc;
- if(num == 6)
- p2 = reptemp.loc;
- gets(buf);
- if(strlen(buf) <= 34 && strlen(buf) > 0) break;
- }
- while(*p1 != 0)
- *p2++ = toupper(*p1++);
- *p2 = 0;
- } /*end of get_data*/
-
- void pl_tone(int b)
- {
- int tone;
- char tbuf[9],*p1,*p2;
- p1 = tbuf;
- tone = (status[bytcnt - b] & 0x3f);
- switch(tone)
- {
- case(0) : p1 = " 67.0"; break;
- case(1) : p1 = " 71.9"; break;
- case(2) : p1 = " 77.0"; break;
- case(3) : p1 = " 82.5"; break;
- case(4) : p1 = " 88.5"; break;
- case(5) : p1 = " 94.8"; break;
- case(6) : p1 = " 100.0"; break;
- case(7) : p1 = " 103.5"; break;
- case(8) : p1 = " 107.2"; break;
- case(9) : p1 = " 110.9"; break;
- case(10) : p1 = " 114.8"; break;
- case(11) : p1 = " 118.8"; break;
- case(12) : p1 = " 123.0"; break;
- case(13) : p1 = " 127.3"; break;
- case(14) : p1 = " 131.8"; break;
- case(15) : p1 = " 136.5"; break;
- case(16) : p1 = " 141.3"; break;
- case(17) : p1 = " 146.2"; break;
- case(18) : p1 = " 151.4"; break;
- case(19) : p1 = " 156.7"; break;
- case(20) : p1 = " 162.2"; break;
- case(21) : p1 = " 167.9"; break;
- case(22) : p1 = " 173.8"; break;
- case(23) : p1 = " 179.9"; break;
- case(24) : p1 = " 186.2"; break;
- case(25) : p1 = " 192.8"; break;
- case(26) : p1 = " 203.5"; break;
- case(27) : p1 = " 210.7"; break;
- case(28) : p1 = " 218.1"; break;
- case(29) : p1 = " 225.7"; break;
- case(30) : p1 = " 233.6"; break;
- case(31) : p1 = " 241.8"; break;
- case(32) : p1 = " 250.3"; break;
- case(33) : p1 = "C 67.0"; break;
- case(34) : p1 = "C 71.9"; break;
- case(35) : p1 = "C 74.7"; break;
- case(36) : p1 = "C 77.0"; break;
- case(37) : p1 = "C 79.7"; break;
- case(38) : p1 = "C 82.5"; break;
- case(39) : p1 = "C 85.4"; break;
- case(40) : p1 = "C 88.5"; break;
- case(41) : p1 = "C 91.5"; break;
- }
- p2 = reptemp.tone;
- while(*p1 != 0)
- *p2++ = *p1++;
- *p2 = 0;
- } /* end of pl_tone */
-
- void edit_control(void)
- {
- char option;
-
- clrscr();
- gotoxy(0,3);
- printf("\t EDIT operates independently from the FT-767GX CAT\n");
- printf("\t function of this program. The FT-767GX need not be\n");
- printf("\t turned on during its use. EDIT allows the direct\n");
- printf("\t viewing, insertion, and/or deletion of station\n");
- printf("\t records into/from the disk memory files. However,\n");
- printf("\t It will only permit one to change a station's call\n");
- printf("\t letters and/or location and comments about it.\n\n");
- printf("\t When added to the files, stations are automatically\n");
- printf("\t placed sorted in frequency order. Therefore,\n");
- printf("\t editing the frequencies can not be permitted.\n\n");
- printf("\t To change a station's frequency, mode or CTCSS tone\n");
- printf("\t remove the station's record from the file and then\n");
- printf("\t add it back into the file with the corrected\n");
- printf("\t information.\n");
- press_enter(33,24);
-
- clrscr();
- printf("\t\t\t Edit disk memories\n\n");
- printf("\t\t\t General Coverage Reception and\n");
- printf("\t\t\t Amateur Band Simplex operation\n\n");
- printf("\t 1 - View the General Stations file\n");
- printf("\t 2 - Edit a General Station Record\n");
- printf("\t 3 - Add Stations to General Coverage disk memory by hand\n");
- printf("\t 4 - Remove Stations from General Coverage disk memory\n");
- printf("\n\t\t\t Amateur Band Split Frequency\n");
- printf("\t\t\t and Repeater Operation\n\n");
- printf("\t 5 - View the Amateur Band Repeater Stations file\n");
- printf("\t 6 - Edit an Amateur Band Repeater Station Record\n");
- printf("\t 7 - Add Stations to Amateur Repeater disk memory by hand\n");
- printf("\t 8 - Remove Stations from Amateur Repeater disk memory\n");
- printf("\n\t 9 - To go to main program\n\n");
- printf("\t Enter selection --- ");
- do
- {
- gotoxy(45,21);
- option = _getch();
- } while((option < '1') || (option > '9'));
- fflush(stdin);
- edit_selection(option);
- } /*end of edit_control*/
-
- char edit_selection(char opt)
- {
- char ch;
- switch(opt)
- {
- case '1': examine_files(3); break;
- case '2': edit_records(2); break;
- case '3': add_station(4); break;
- case '4': delete_station(5); break;
- case '5': examine_files(8); break;
- case '6': edit_records(7); break;
- case '7': add_station(9); break;
- case '8': delete_station(10); break;
- default: return(0);
- }
- do
- {
- CLRSCR;
- gotoxy(0,10);
- printf("\n\t\t\t 1 - Run CAT program\n");
- printf("\t\t\t 2 - Return to DOS\n");
- printf("\n\t\t\t\tEnter selection --- ");
- ch = _getch();
- if(ch == '2') exit(0);
- else
- if(ch == '1') ;
- }
- while((ch > '2') || (ch < '1'));
- } /*end of edit_selection*/
-
- void edit_records(int num)
- {
- int record_cnt,ed_rec;
-
- for(;;)
- {
- record_cnt = loadfile(num);
- if(record_cnt == -3) break;
-
- do
- {
- viewfile(record_cnt,num);
- gotoxy(0,24);
- CLREOL;
- gotoxy(13,24);
- printf("Enter the MEM number of the station record to be edited --- ");
- scanf("%d",&ed_rec);
- ed_rec--;
- }
- while((ed_rec < 1) || (ed_rec > record_cnt));
-
- if((ed_rec == 1) && (record_cnt == 0))
- {
- if(num == 2)
- system("del general.dat");
- if(num == 7)
- system("del repeater.dat");
- }
- else
- {
- edit_station_record(ed_rec,num);
- if(num == 2)
- savedata(record_cnt,num);
- if(num == 7)
- savedata(record_cnt,num);
- }
- clrscr();
- gotoxy(0,6);
- if(num == 2)
- printf("The station's call letters are now %s\n",g[ed_rec].call);
- if(num == 7)
- printf("The station's call letters are now %s\n",r[ed_rec].call);
- if(num == 2)
- printf("The station's location and/or comment is now %s\n",g[ed_rec].loc);
- if(num == 7)
- printf("The station's location and/or comment is now %s\n",r[ed_rec].loc);
-
- gotoxy(0,12);
- printf("\n\n\t\tEdit another station record? y or n --- ");
- if(getreply() == 1) break;
- }
- } /*end of edit_records*/
-
- void edit_station_record(int rec, int num)
- {
- int i;
- char buf[42],*p1,*p2;
- #undef toupper
- clrscr();
- printf("\n\n\n");
- if(num == 2)
- printf("The call letters are now %s\n",g[rec].call);
- if(num == 7)
- printf("The call letters are now %s\n",r[rec].call);
- printf("Do you wish to edit the call letters? y or n --- ");
- if(getreply() == 1) putchar('\n');
- else
- {
- putchar('\n');
- fflush(stdin);
- while(TRUE)
- {
- printf("Enter Station's Call Letters ________");
- backup(7);
- p1 = buf;
- if(num == 2)
- p2 = g[rec].call;
- if(num == 7)
- p2 = r[rec].call;
- for(i = 0;i <= 8;i++)
- *p2++ = 0;
- if(num == 2)
- p2 = g[rec].call;
- if(num == 7)
- p2 = r[rec].call;
- gets(buf);
- if(strlen(buf) <= 8 && strlen(buf) > 0) break;
- }
- while(*p1 != 0)
- {
- if(isalpha(*p1) != 0)
- *p2++ = toupper(*p1++);
- else
- *p2++ = *p1++;
- }
- }
- printf("\n\n\n");
- if(num == 2)
- printf("The location and/or comment is now %s\n",g[rec].loc);
- if(num == 7)
- printf("The location and/or comment is now %s\n",r[rec].loc);
- printf("Do you wish to edit the location and/or comment? y or n --- ");
- if(getreply() == 1) putchar('\n');
- else
- {
- putchar('\n');
- fflush(stdin);
- while(TRUE)
- {
- printf("Enter Information __________________________________");
- backup(33);
- p1 = buf;
- if(num == 2)
- p2 = g[rec].loc;
- if(num == 7)
- p2 = r[rec].loc;
- for(i = 0;i <= 34;i++)
- *p2 = 0;
- if(num == 2)
- p2 = g[rec].loc;
- if(num == 7)
- p2 = r[rec].loc;
- gets(buf);
- if(strlen(buf) <= 34 && strlen(buf) > 0) break;
- }
- while(*p1 != 0)
- *p2++ = toupper(*p1++);
- *p2 = 0;
- }
- } /*end of edit_station_record*/
-